package com.sunbim.rsrv.pojo;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.sunbim.rsrv.pojo.typeHandler.BodyJsonTypeHandler;
import com.sunbim.rsrv.pojo.typeHandler.StructJsonTypeHandler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 本体劣化风险-砖木构古建筑
 * </p>
 *
 * @author yuhui
 * @since 2021-12-30
 */
@Getter
@Setter
@TableName("risk_body")
@ApiModel(value = "RiskBody对象", description = "砖木构古建筑")
public class RiskBody implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("所属用户id")
    @TableField("user_id")
    @JsonProperty("user_id")
    private Integer userId;

    @ApiModelProperty("所属文物id")
    @TableField("relics_id")
    @JsonProperty("relics_id")
    private Integer relicsId;

    @ApiModelProperty("本体风险")
    @TableField(value = "body", typeHandler = BodyJsonTypeHandler.class)
    private Body body;

    @ApiModelProperty("结构风险")
    @TableField(value = "category", typeHandler = StructJsonTypeHandler.class)
    private Category category;

    @ApiModelProperty("主要问题")
    @TableField("problem")
    private String problem;

    @ApiModelProperty("文物结构类别")
    @TableField("category_index")
    private String categoryIndex;

    @ApiModelProperty("总分")
    @TableField("total_score")
    private Integer totalScore = 0;

    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @JsonProperty(value = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @JsonProperty(value = "update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;


    @Data
    public static class Body {
        //        @ApiModelProperty("屋顶")
//        @TableField("roofing")
//        @NotNull(message = "屋顶风险分数不能为空")
//        private Integer roofing = 0;
//
//        @ApiModelProperty("室内外地面")
//        @TableField("floors")
//        @NotNull(message = "室内外地面风险分数不能为空")
//        private Integer floors = 0;
//
//        @ApiModelProperty("室内外墙面")
//        @TableField("wall")
//        @NotNull(message = "室内外墙面风险分数不能为空")
//        private Integer wall = 0;
//
//        @ApiModelProperty("其他构件")
//        @TableField("other")
//        @NotNull(message = "其他构件风险分数不能为空")
//        private Integer other = 0;
//
//        @ApiModelProperty("历史修缮部位")
//        @TableField("parts")
//        @NotNull(message = "历史修缮部位风险分数不能为空")
//        private Integer parts = 0;
        @ApiModelProperty("风险项")
        @TableField("risk")
        private List<Map<String, Object>> risk;

        @ApiModelProperty("本体劣化风险")
        @TableField("title")
        private String title;

        @ApiModelProperty("风险等级")
        @JsonProperty("level")
        @TableField(exist = false)
        private Integer level = 0;

        @ApiModelProperty("总分")
        @TableField("score")
        private Integer score = 0;

        public Body() {
        }
    }

    @Data
    public static class Category {

        //        @ApiModelProperty("单个构件")
//        @TableField("single")
//        @NotNull(message = "单个构件风险分数不能为空")
//        private Integer single = 0;
//
//        @ApiModelProperty("节点及连接")
//        @TableField("node")
//        @NotNull(message = "节点及连接风险分数不能为空")
//        private Integer node = 0;
//
//        @ApiModelProperty("结构整体性")
//        @TableField("overall")
//        @NotNull(message = "结构整体性风险分数不能为空")
//        private Integer overall = 0;

        @ApiModelProperty("风险项")
        @TableField("risk")
        private List<Map<String, Object>> risk;

        @ApiModelProperty("本体劣化风险")
        @TableField("title")
        private String title;

        @ApiModelProperty("总分")
        @TableField("score")
        private Integer score = 0;

        @ApiModelProperty("风险等级")
        @TableField(exist = false)
        private Integer level = 0;

        public Category() {
        }
    }
}


